/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: javase2203 - Arr8
 * <p>Powered by webrx On 2022-07-12 16:04:21
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr8 {
    public static void main(String[] args) {
        String[] langs = {"java", "c", "go", "python", "c++", "javascript", "c#"};
        //按字母顺序
        //System.out.println(Arrays.toString(langs));

        //升序
        //Arrays.sort(langs);
        //System.out.println(Arrays.toString(langs));

        //降序
        //Arrays.sort(langs, (a, b) -> b.compareTo(a));
        //System.out.println(Arrays.toString(langs));

        //乱序
        //Arrays.sort(langs, (a, b) -> Math.random() > .5 ? 1 : -1);
        //System.out.println(Arrays.toString(langs));


        //字符串长度
        System.out.println(Arrays.toString(langs));

        Arrays.sort(langs,(a,b)->a.length()-b.length());
        System.out.println(Arrays.toString(langs));

        Arrays.sort(langs,(a,b)->b.length()-a.length());
        System.out.println(Arrays.toString(langs));
    }
}
